use {
    crate::model::dapp_centralized_config::DAppCentralizedConfig,
    sqlx::{MySql, Pool},
};

impl DAppCentralizedConfig {
    pub async fn select_by_chain(
        chain: &str,
        pool: &Pool<MySql>,
    ) -> anyhow::Result<DAppCentralizedConfig> {
        let query = sqlx::query_as::<_, DAppCentralizedConfig>(
            r#"SELECT * FROM dapp_centralized_config where `chain`= ? "#,
        )
        .bind(chain.to_string());

        let row = query.fetch_one(pool).await?;

        Ok(row)
    }
}
